Những câu hỏi liên quan
Lê Tâm Anh
Xem chi tiết
gấu béo
7 tháng 5 2023 lúc 19:20

program Le_Nho_Hon_Hoac_Bang_n;

uses crt;

var

       n, i: integer;

begin

       clrscr;

       write('Nhap vao mot so nguyen duong n: ');

       readln(n);

       while n <= 0 do

       begin

              writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');

              readln(n);

       end;

       clrscr;

       writeln('Cac so le nho hon hoac bang ', n, ' la:');

       i := 1;

       while i <= n do

       begin

              if i mod 2 <> 0 then

                     writeln(i);

              i := i + 1;

       end;

       readln;

end.

Bình luận (0)
thanh mai
Xem chi tiết
Thanh Phong (9A5)
11 tháng 4 2023 lúc 15:22

Cách 1 dùng lệnh for do:

Uses crt;

var i,n,k: integer;

begin clrcsr;

readln(n);

for i:=1 to n do begin

if(i mod 2=0) and (i>=10) then k:=k*i;

end;

writeln(k);

readln;

end.

Cách 2 dùng lệnh while do

Uses crt;

var m,n,o: integer;

begin clrcsr;

readln(n);

o:=1;

m:=1;

while (m<n) do begin

m:=m+1;

if(m mod 2=0) and (m>=10) then o:=o*m;

end;

writeln(o);

readln;

end.

Bình luận (0)
Thư Uyên
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 3 2021 lúc 20:05

Bài 1: 

uses crt;

var n,i,s:integer;

begin

clrscr;

write('Nhap n='); readln(n);

s:=0;

i:=1;

while i<=n do 

  begin

s:=s+i;

inc(i);

end;

writeln('Tong cac so trong khoang tu 1 den ',n,' la: ',s);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
26 tháng 3 2021 lúc 20:07

Bài 2: 

uses crt;

var n,i,s:integer;

begin

clrscr;

write('Nhap n='); readln(n);

s:=0;

i:=1;

while i<=n do 

  begin

s:=s+i;

i:=i+2;

end;

writeln('Tong cac so le trong khoang tu 1 den ',n,' la: ',s);

readln;

end.

Bình luận (0)
NgocTuan
3 tháng 1 2022 lúc 20:13

alo

Bình luận (0)
Hi HI Hi
Xem chi tiết
Kiều Vũ Linh
25 tháng 3 2022 lúc 9:17

var a:integer;

begin

a:=500;

writeln('cac so chia het cho 7 la:');

while a>=200 do

begin

if a mod 7 = 0 then writeln(a);

a:=a-1;

end;

readln;

end.

Bình luận (0)
Khánh Hoàng
Xem chi tiết
Minh Lệ
7 tháng 3 2023 lúc 22:51

Program HOC24;

var i,n: integer;

S: longint;

begin

write('Nhap N: '); readln(n);

i:=2; s:=0;

while i<=n do

begin

s:=s+i;

i:=i+2;

end;

write('S=',S);

readln

end.

Bình luận (0)
Nguyễn Hoàng Duy
19 tháng 3 2023 lúc 22:42

program TongCacSoChan;
var
    n, s, i: integer;
begin
    write('Nhap n: ');
    readln(n);
    s := 0;
    i := 2;
    while i <= n do
    begin
        s := s + i;
        i := i + 2;
    end;
    writeln('Tong cac so chan la: ', s);
    readln;
end.

 

Bình luận (0)
NQ Thi
Xem chi tiết
Nguyễn Hoàng Duy
4 tháng 4 2023 lúc 0:03

program Tinh_Tong;

var n, s, i: integer;

begin
  write('Nhap vao so nguyen duong n: ');
  readln(n);
  s := 0;
  i := 1;
  while i <= n do
  begin
    s := s + i;
    i := i + 1;
  end;
  writeln('Tong cua ', n, ' so tu nhien dau tien la: ', s);
  end.

Bình luận (0)
Huỳnh Hoài Nguyên
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 3 2021 lúc 22:23

uses crt;

var i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

i:=1;

t:=0;

while i<=n do 

begin

if i mod 2=0 then t:=t+i;

i:=i+1;

end;

write(t);

readln;

end.

Bình luận (0)
Nguyễn Gia Huy
Xem chi tiết
Thanh Phong (9A5)
15 tháng 3 2023 lúc 5:50

Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do if( i mod 2<>0) then write(i:3);

readln;

end.

 

Bình luận (0)
Lê Gia Anh
19 tháng 3 2023 lúc 20:25

uses crt;

var i,n:longint;

begin 

writeln('nhap n'); readln(n);

for i:=1 to n do if i mod 2 =1 then 

writeln(i);

readln;

end.

ngu ththế mà cũng ko làm được về lớp 1 mà học

Bình luận (0)
Trần Thị Mai Ngọc
Xem chi tiết
nguyễn an phát
18 tháng 4 2021 lúc 20:48

program tim_uoc;

uses crt;

var i,n,tong:integer;

begin

clrscr;

write('nhap so n:');readln(n);

i:=1;tong:=0;

writeln('cac uoc cua ',n,' la:');

while i<=n do

if n mod i=0 then

begin

write(i:3);

inc(i);

end;

writeln;

i:=1;writeln('cac uoc chan:');

while i<=n do

begin

if n mod i=0 then 

begin

if i mod 2=0 then write(i:3);

tong:=tong+i;

end;

end;

writeln;

write('tong cac uoc chan:',tong);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
19 tháng 4 2021 lúc 19:17

uses crt;

var n,i,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

i:=1;

writeln('Cac uoc cua ',n,' la: ');

while i<=n do

  begin

if n mod i=0 then write(i:4):

i:=i+1;

end;

writeln;

writeln('Cac uoc chan cua ',n,' la: ');

t:=0;

i:=1;

while i<=n do 

  begin

if (n mod i=0) then

begin

t:=t+i;

write(i:4);

end;

inc(i);

end;

writeln('Tong cac uoc chan cua ',n,' la: ',t);

readln;

end.

Bình luận (0)